package com.hkts.beltweigher.master.service.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hkts.beltweigher.master.entity.User;
import com.hkts.beltweigher.master.mapper.UserMapper;
import com.hkts.beltweigher.master.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;
/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hml
 * @since 2024-04-23
 */
@Service
@Transactional
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {


    @Autowired
    private UserMapper userMapper;

    @Override
    public IPage<User> selectPage(Page<User> page, User user){
        QueryWrapper<User> query=Wrappers.query();
        return userMapper.selectPage(page,query);
        }


    @Override
    public List<User> selectList(User user){
        QueryWrapper<User> query=Wrappers.query();
        return userMapper.selectList(query);
        }

    @Override
    public User getUserByUserName(String username) {
        QueryWrapper<User> query=Wrappers.query();
        query.lambda().eq(User::getUserName,username);
        User user = userMapper.selectOne(query);
        return user;
    }


}
